package com.common.singleton;

/**
 * 懒汉模式:线程不安全
 * Created by Administrator on 2018-9-13 0013.
 */
public class SingletonLazyNotSafe {

    private static SingletonLazyNotSafe SINGLETON_LAZY_NOT_SAFE;

    private SingletonLazyNotSafe(){}


    /**
     * 就算是加了休眠1秒钟线程也不见得安全
     * @return
     */
    public static SingletonLazyNotSafe getInstance(){
        if(SINGLETON_LAZY_NOT_SAFE == null){
            try {
                Thread.sleep(1000);
                SINGLETON_LAZY_NOT_SAFE = new SingletonLazyNotSafe();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        return SINGLETON_LAZY_NOT_SAFE;
    }

}
